<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
     <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <style>
        .checkbox-inline input[type=checkbox], .radio-inline input[type=radio] {
            margin-top: 4px;
        }

        .note-editable {
            height: 150px
        }

        .cb_box {
            display: none;
        }

        .activeA {
            color: red;
        }

        .cbActive {
            display: block;
        }

        .tdMax {
            min-width: 60px;
            max-width: 120px;
        }

        .textEff {
            border: 0;
            background-color: #efffff;
            width: 200px
        }

        .textSomeTd {
            min-width: 160px;
            width: 160px;
        }
    </style>
</head>

<body style="color:#333;padding:3px;" onload="resize();" onresize="resize();">
<!-- 标题 -->
<div class="page-heade">
    <h1 class="title_color padding-10">经销商合同管理--添加合同</h1>
</div>
<!-- 标题 -->
<div class="row-margin-top">
     <form id="f1"  method="post"  class="form-inline">
      <input type="hidden" name="kid" id="kid" value='{$kid}'/>
      <input type="hidden" name="state" value="" id="state"/>
      <input type="hidden" name="jxs_name" id="jxs_name" {if $kid} value="{$jxs.title}" {/if}/>
      <input type="hidden" name="mxtype" id="mxtype" {if $kid} value="{$apply.detail_type}" {else/} value="1" {/if}/>
        <table class="table-bordered table t_table">
            <tr class="info">
                <th colspan="4" class="font-bold">经销商基本信息</th>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">经销商<span
                        class="colorRed">*</span>:</label></td>
                <td colspan="3">
                    <div style="width:300px;height:30px;float:left;">
                        <div class="input-group" id="cusName_input" {if $kid} style='display:none;'{/if} >
                            <input type="text" placeholder="请输入关键字或空格查询" class="form-control" id="cusName"  >
                            <div class="input-group-btn">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                </ul>
                            </div>
                        </div>
                        <div id="cusName_queding" class="selectedOnlyOne" {if $kid} {else/} style="display: none;"{/if}>
                            <input type="hidden" name="jxs" {if $kid} value="{$jxs.id}"{else/} value=""{/if}>
                            <span class="inin">{if $kid}{$jxs.title}{/if}</span>
                            <span class="close">×</span>
                        </div>
                    </div>
                    <a href="javascript:;" id="selectCus" style="float:left;">选择<span class="helpText">帮</span></a>

                    <div style="clear:both;">
                        {if $kid}
                        {else/}
                        温馨提示：如果经销商名称没有列示，请先申请开户！<a class="addnew num2 ObjectNum" title="开户申请" href="{:url('kaihu')}">点击立即开户申请</a>
                        {/if}
                        
                    </div>
                </td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">经销商编号:</label></td>
                <td><input type="text" name="jxsbh"  readonly {if $kid} value="{$jxs.sn}" {/if} class="textEff"></td>
                <td style="min-width: 160px;width: 160px" class="text-right"><label for=""  class="form-label">合作年限:</label>
                </td>
                <td><input type="text" name="hznx" class="textEff" {if $kid} value="{$jxs.cooptime}" {/if} readonly></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">渠道类型:</label></td>
                <td><input type="text"  name="qdlx" class="textEff" {if $kid} value="{$jxs.qudao}" {/if} readonly></td>
                <td style="min-width: 160px;width: 160px" class="text-right"><label for=""  class="form-label">营业地址类型:</label>
                </td>
                <td>
                    <label class="radio-inline">
                        <input type="radio" name="yydzlx" id="inlineRadio1"{if $kid} {if $apply.yydzlx==1} checked {/if} {else/} checked {/if} value="1">省级
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="yydzlx" id="inlineRadio2" value="2" {if $kid} {if $apply.yydzlx==2} checked {/if}{/if}>市级
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="yydzlx" id="inlineRadio3" value="3" {if $kid} {if $apply.yydzlx==3} checked {/if}{/if}>县级
                    </label>
                </td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">营业地址<span class="colorRed">*</span>:</label>
                </td>
                <td colspan="3">
                    <div class="form-group" style="margin:2px 0">
                        省：<select name="yydz_provice" id="yydzp" class="form-control">
                        <option value="">请选择</option>
                        {volist name="provices" id="row"}
                        <option value="{$row.id}">{$row.title}</option>
                        {/volist}
                    </select>
                        市：<select name="yydz_city" id="" class="form-control">
                        <option value="">请选择</option>
                    </select>
                        县或区：<select name="yydz_county" id="" class="form-control">
                        <option value="">请选择</option>
                    </select>
                   
                    </div>
                    <br>
                    <div class="form-group" style="margin:2px 0">
                        详细地址：<input type="text" class="form-control" name="yddz_xxdz" {if $kid} value="{$apply.yddz_xxdz}" {/if} style="min-width: 240px;">
                    </div>
                </td>
            </tr>
        </table>
        <table class="table-bordered table t_table">
            <tr class="info">
                <th colspan="2" class="font-bold">合同名称及编号：</th>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">合同名称:</label></td>
                <td class="font-bold" id="htmc">
                {if $kid}
                    {$jxs.title}-<input type="text" name="htmc_nf" onblur="xiugaihetong(5)" value="{$apply.htmc_nf}" class="form-control" style="">年合同
                {/if}
                </td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">合同编号:</label></td>
                <td><input type="text" name="htbh" class="textEff" readonly {if $kid} value="{$apply.htbh}" {/if}></td>
            </tr>
        </table>
        <table class="table-bordered table t_table">
            <tr class="info">
                <th colspan="4" class="font-bold">授权信息：</th>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">合同有效期: <span
                        class="colorRed">*</span></label></td>
                <td>
                    <div class="form-group">
                        <input type="text" id="start" class="form-control layer-date "
                               style="width:120px;display: inline-block;" name="htyxq_start" {if $kid} value="{$apply.start}" {/if}>
                    </div>
                    <div class="form-group">
                        至
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control layer-date" style="width:120px;display: inline-block;"
                               id="end" name="htyxq_end" {if $kid} value="{$apply.end}" {/if}>
                    </div>
                </td>
                <td style="min-width: 200px;width: 200px" class="text-right"><label for="" class="form-label">合同销售目标:</label>
                </td>
                <td><input type="text" name="htxsmb" class="textEff tarzong" readonly  {if $kid} value="{$apply.htxsmb}" {/if}></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">预算费用目标<br>(万元):</label></td>
                <td><input type="text" name="ysfymb" class="textEff salezong" readonly  {if $kid} value="{$apply.ysfymb}" {/if}></td>
                <td style="min-width: 200px;width: 200px" class="text-right"><label for="" class="form-label">目标费用率:</label>
                </td>
                <td><input type="text" name="mbfyl" class="textEff" readonly  {if $kid} value="{$apply.mbfyl}" {/if}>%</td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">授权品牌<span class="colorRed">*</span>:</label>
                </td>
                <td colspan="3">
                    <input type="text" name="sqppstr"  {if $kid} value="{$apply.sqppstr}" {/if} placeholder="" style="width:60%" class="form-control" id="sqpp" readonly>
                    <input type="hidden" name="sqpp"  {if $kid} value="{$apply.sqpp}" {/if}>
                    <a href="javascript:;" id="select_sqpp" style="">选择</a>
                </td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">授权品类<span class="colorRed">*</span>:</label>
                </td>
                <td colspan="3">
                    <input type="text" name="sqplstr"  {if $kid} value="{$apply.sqplstr}" {/if} placeholder="" style="width:60%" class="form-control" id="sqpl" readonly>
                    <input type="hidden" name="sqpl"  {if $kid} value="{$apply.sqpl}" {/if}>
                    <a href="javascript:;" id="select_sqpl" >选择</a>
                </td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">经销类型:</label></td>
                <td colspan="3">
                    <label class="radio-inline">
                        <input type="radio" {if $kid}{if $apply.jxlx==1}checked {/if}{else/}checked{/if} name="jxlx" value="1">区域型经销
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="jxlx" value="2" {if $kid}{if $apply.jxlx==2}checked{/if}{/if}>系统型经销
                    </label>
                </td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label"><span id="sqbt">授权区域</span><span class="colorRed">*</span>:</label>
                </td>
                <td colspan="3">
                    <div class="form-group" id="sready" style="width:100%">
                        <textarea  id="sqqystr" name="sqqystr"  readonly="" style="width:80%;height:100px;resize: none;"> {if $kid}{$apply.sqqystr}{/if}</textarea>
                        <br>
                        <input type="hidden" name="sqqy" id="sqqy"  {if $kid} value="{$apply.sqqy}" {/if}>
                        <a href="javascript:;" id="select_sqqy">选择</a>
                    </div>
                    <div class="form-group" id="swork" style="display: none;">
                        <input type="text" class="form-control" name="sqxt"  {if $kid} value="{$apply.sqxt}" {/if}>
                    </div>
                </td>
            </tr>
        </table>
        <table class="table-bordered table " id="re_table">
            <tr>
                <th class="info font-bold">销售与预算目标分解(单位:万元)</th>
            </tr>
            <tr>
                <td class="changeBtn">
                    <button type="button" class="btn btn-info btn-outline mxbtn {if $kid}{if $apply.detail_type==1}active{/if}{/if}" mxtid="1">默认</button>
                    <button type="button" class="btn btn-info btn-outline mxbtn {if $kid}{if $apply.detail_type==2}active{/if}{/if}" mxtid="2">按品牌</button>
                    <button type="button" class="btn btn-info btn-outline mxbtn {if $kid}{if $apply.detail_type==3}active{/if}{/if}" mxtid="3">按品类</button>
                    <button type="button" class="btn btn-info btn-outline mxbtn {if $kid}{if $apply.detail_type==4}active{/if}{/if}" mxtid="4">按系列</button>
                    <button type="button" class="btn btn-info btn-outline" onclick="zidingyi()">自定义</button>
                </td>
            </tr>
            <tr>
                <td class="showInfo" style="padding: 2px;">
                    <div class="cb_box" {if $kid} style="display: block;"{/if}>
                        <table class="table table-bordered text-center" style="margin: 0">
                            
                            <thead>
                                <tr>
                                    <td rowspan="2">时间</td>
                                    <td>销售(销售)目标</td>
                                    <td>预算(费用)目标</td>
                                </tr>
                                <tr>
                                   <td id="title1" style="padding: 0">
                                        {if $kid}
                                            <table class='table-bordered' style='width:100%'><tr>
                                            {volist name="lans" id="t" key='j'}
                                                <td class='text-center' style='min-width:150px' xh='{$j}'><input type='hidden' name='prolist[]' value='{$t}'/>{$t}<br/><input type='button' value='删除' onclick='shanchuduiying({$j})'/></td>
                                            {/volist}
                                            <td class='text-center' style='min-width:150px'>小计</td></tr></table>
                                        {/if}
                                   </td>
                                   <td id="title2" style="padding: 0">
                                        {if $kid}
                                            <table class='table-bordered' style='width:100%'><tr>
                                            {volist name="lans" id="t" key='j'}
                                                <td class='text-center' style='min-width:150px' xh='{$j}'>{$t}<br/><input type='button' value='删除' onclick='shanchuduiying({$j})'/></td>
                                            {/volist}

                                            <td class='text-center' style='min-width:150px'>小计</td></tr></table>
                                        {/if}
                                   </td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td style="padding: 0" id="timelan">
                                        {if $kid}
                                        <table class='table-bordered' style='width:100%'>
                                            {volist name="kaohe2" id="k2"}
                                                    <tr><td class='text-center' style='min-width:100px'><input type='hidden' name='kaohe2[]' value='{$k2.k2id}'/>{$k2.cainian}年-{$k2.yue}</td></tr>
                                            {/volist}

                                        </table>
                                        {/if}
                                    </td>
                                    <td id="neirong1" style="padding: 0">
                                        {if $kid}
                                            <table class='table-bordered' style='width:100%'>
                                                {volist name="kaohe2" id="k2"}
                                                    <tr namez='sale_target[{$k2.k2id}][]'>
                                                        {volist name="sale_target[$k2.k2id]" id="s" key="j" }
                                                            {if $j<=$xh}
                                                            <td style='min-width:150px' xh='{$j}'><input type='text' style='width:100px' class='form-control' name='sale_target[{$k2.k2id}][]' onblur='xiaoshoujisuan()' value="{$s}"/></td>
                                                            {/if}
                                                        {/volist}
                                                            {if $apply.detail_type==1}
                                                            {volist name="sale_target[$k2.k2id]" id="s" key="j" }
                                                           <td style='min-width:150px'><input type='text' style='width:300px' class='form-control xstar' onblur='morenxsjisuan()' name='sale_target[{$k2.k2id}][]' value="{$s}"/></td>
                                                            {/volist}
                                                            {else/}
                                                             <td style='min-width:150px'><input type='text' style='width:100px' class='form-control' name='sale_target[{$k2.k2id}][]' readonly/></td>
                                                            
                                                            
                                                            {/if}

                                                    </tr>
                                                {/volist}
                                            </table>
                                        {/if}
                                    </td>
                                    <td id="neirong2" style="padding: 0">
                                        {if $kid}
                                            <table class='table-bordered' style='width:100%'>
                                                {volist name="kaohe2" id="k2"}
                                                    <tr namez='yusuan_target[{$k2.k2id}][]'>
                                                        {volist name="yusuan_target[$k2.k2id]" id="s" key="j" }
                                                            {if $j<=$xh}
                                                            <td style='min-width:150px' xh='{$j}'><input type='text' style='width:100px' class='form-control' name='yusuan_target[{$k2.k2id}][]' onblur='yusuanjisuan()' value="{$s}"/></td>
                                                            {/if}
                                                        {/volist}
                                                        {if $apply.detail_type==1}
                                                            {volist name="yusuan_target[$k2.k2id]" id="s" key="j" }
                                                           <td style='min-width:150px'><input type='text' style='width:300px' class='form-control ystar' onblur='morenysjisuan()' name='yusuan_target[{$k2.k2id}][]' value="{$s}"/></td>
                                                            {/volist}
                                                            {else/}
                                                             <td style='min-width:150px'><input type='text' style='width:100px' class='form-control' name='yusuan_target[{$k2.k2id}][]' readonly/></td>
                                                            
                                                            
                                                        {/if}
                                                    </tr>
                                                {/volist}

                                            </table>
                                        {/if}

                                    </td>
                                </tr>
                            </tbody>
                            <tr>
                                <td>总计</td>
                                <td><input type="text" name="" class="form-control tarzong" readonly></td>
                                <td><input type="text" name="" class="form-control salezong" readonly></td>
                            </tr>
                        </table>
                    </div>
                  
                </td>
            </tr>
        </table>
        <table class="table-bordered table t_table">
            <tr class="info">
                <th colspan="4" class="font-bold">合同提交人信息及提交时间：</th>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">合同提交人:</label></td>
                <td><input type="text" value={$user.em_name} class="textEff" readonly></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">合同提交时间:</label></td>
                <td><input type="text" value="{$today}" class="textEff" readonly></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">提交人所在部门:</label></td>
                <td><input type="text" value="{$user.de_name}" class="textEff" readonly></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">提交人联系方式:</label></td>
                <td><input type="text" value="{$user.mobile}" class="textEff" readonly></td>
            </tr>
        </table>
        <table class="table-bordered table t_table">
            <tr class="info">
                <th colspan="4" class="font-bold">经销商财务信息：</th>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">法定代表人<span class="colorRed">*</span>:</label>
                </td>
                <td><input type="text" name="cw_legalrepre" {if $kid} value="{$apply.cw_legalrepre}" {/if} class="form-control" id="legal_people"></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">法人固定电话:</label></td>
                <td><input type="text" name="cw_lrphone" {if $kid} value="{$apply.cw_lrphone}" {/if}  class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">法人手机:</label></td>
                <td><input type="text" name="cw_lrmobile" {if $kid} value="{$apply.cw_lrmobile}" {/if} class="form-control"></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">法人电子邮箱:</label></td>
                <td><input type="text" name="cw_lremail" {if $kid} value="{$apply.cw_lremail}" {/if} class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">纳税资格:</label></td>
                <td>
                    <label class="radio-inline">
                        <input type="radio" {if $kid}{if $apply.cw_qualification==0} checked {/if}{else/} checked {/if} name="cw_qualification"  id="agency1" value="0">一般纳税人
                    </label>
                    <label class="radio-inline">
                        <input type="radio" {if $kid}{if $apply.cw_qualification==1} checked {/if}{/if} name="cw_qualification" id="agency2" value="1">小规模纳税人
                    </label>
                </td>
                <td class="text-right textSomeTd"><label for="" class="form-label">税号<span
                        class="colorRed">*</span>:</label></td>
                <td><input type="text" name="cw_taxsn" {if $kid} value="{$apply.cw_taxsn}" {/if} class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">开户行<span
                        class="colorRed">*</span>:</label></td>
                <td><input type="text" name="cw_bank" {if $kid} value="{$apply.cw_bank}" {/if} class="form-control"></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">账号<span
                        class="colorRed">*</span>:</label></td>
                <td><input type="text" name="cw_banksn" {if $kid} value="{$apply.cw_banksn}" {/if} class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">邮寄地址<span class="colorRed">*</span>:</label>
                </td>
                <td><input type="text" name="cw_mailaddr" {if $kid} value="{$apply.cw_mailaddr}" {/if} class="form-control" id="legal_address"></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">邮编<span
                        class="colorRed">*</span>:</label></td>
                <td><input type="text" name="cw_zipcode" {if $kid} value="{$apply.cw_zipcode}" {/if} class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">财务联系人:</label></td>
                <td><input type="text" name="cw_contact" {if $kid} value="{$apply.cw_contact}" {/if} class="form-control"></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">财务联系电话:</label></td>
                <td><input type="text" name="cw_phone" {if $kid} value="{$apply.cw_phone}" {/if} class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">财务电子邮箱:</label></td>
                <td colspan="3">
                    <input type="text" name="cw_email" {if $kid} value="{$apply.cw_email}" {/if} class="form-control" style="margin-right: 25%;">
                    <button class="btn btn-info" type="button" id="same_faren">同法人联系方式</button>
                    <button class="btn btn-info" type="button" style="margin: 0 20px" id="arti_legal">签署人为法人</button>
                </td>
            </tr>
        </table>
        <table class="table-bordered table t_table">
            <tr class="info">
                <th colspan="4" class="font-bold">业务联系资料：</th>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">业务联系人<span class="colorRed">*</span>:</label>
                </td>
                <td><input type="text" name="bs_contact" {if $kid} value="{$apply.bs_contact}" {/if} class="form-control"></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">业务联系固定电话<span
                        class="colorRed">*</span>:</label></td>
                <td><input type="text" name="bs_phone" {if $kid} value="{$apply.bs_phone}" {/if} class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">业务联系手机<span class="colorRed">*</span>:</label>
                </td>
                <td><input type="text" name="bs_mobile" {if $kid} value="{$apply.bs_mobile}" {/if} class="form-control"></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">业务联系传真<span class="colorRed">*</span>:</label>
                </td>
                <td><input type="text" name="bs_fax" {if $kid} value="{$apply.bs_fax}" {/if} class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">收货单位<span class="colorRed">*</span>:</label>
                </td>
                <td><input type="text" name="bs_rcv_unit" {if $kid} value="{$apply.bs_rcv_unit}" {/if} class="form-control"></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">收货地址<span class="colorRed">*</span>:</label>
                </td>
                <td><input type="text" name="bs_rcv_addr" {if $kid} value="{$apply.bs_rcv_addr}" {/if} class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">收货人<span
                        class="colorRed">*</span>:</label></td>
                <td><input type="text" name="bs_rcv_one" {if $kid} value="{$apply.bs_rcv_one}" {/if} class="form-control"></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">收货人电话<span class="colorRed">*</span>:</label>
                </td>
                <td><input type="text" name="bs_rcv_phone" {if $kid} value="{$apply.bs_rcv_phone}" {/if} class="form-control"></td>
            </tr>
        </table>
        <table class="table-bordered table t_table">
            <tr class="info">
                <th colspan="4" class="font-bold">合同其他信息：</th>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">合同签署时间<span class="colorRed">*</span>:</label>
                </td>
                <td>
                    <input id="startDate" class="form-control layer-date" name="qstime" {if $kid} value="{$apply.qstime}" {/if}>
                </td>
                <td class="text-right textSomeTd"><label for="" class="form-label">我方签署人<span class="colorRed">*</span>:</label>
                </td>
                <td>
                     <div class="container-fluid">
                            <div class="row">
                                <div class="col-xs-10">
                                    <div class="input-group" style="display: none;" >
                                        <input type="text" placeholder="请输入关键字或空格查询" class="cname form-control"  name="wofanguser" value="{$user.id}">
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                                <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                            </ul>
                                        </div>
                                    </div>
                                    <div class="selectedOnlyOne "  >
                                      
                                        <span class="inin">{$user.em_name}</span>
                                        <span class="close">×</span>
                                    </div>
                                </div>
                               
                           </div>
                        </div>
                </td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">对方签署人<span class="colorRed">*</span>:</label>
                </td>
                <td><input type="text" name="df_ren" {if $kid} value="{$apply.df_ren}" {/if} class="form-control" id="thislegal_people"></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">对方签署人职位<span
                        class="colorRed">*</span>:</label></td>
                <td><input type="text" name="df_job" {if $kid} value="{$apply.df_job}" {/if} class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">对方签署人电话<span
                        class="colorRed">*</span>:</label></td>
                <td><input type="text" name="df_phone" {if $kid} value="{$apply.df_phone}" {/if} class="form-control"></td>
                <td class="text-right textSomeTd"><label for="" class="form-label">对方签署人邮箱<span
                        class="colorRed">*</span>:</label></td>
                <td><input type="text" name="df_email" {if $kid} value="{$apply.df_email}" {/if} class="form-control"></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">对方签署人地址<span
                        class="colorRed">*</span>:</label></td>
                <td colspan="3"><input type="text" name="df_addr" {if $kid} value="{$apply.df_addr}" {/if} class="form-control" style="width:80%" id="thislegal_address"></td>
            </tr>
            <tr>
                <td class="text-right textSomeTd"><label for="" class="form-label">是否为特殊合同<span
                        class="colorRed">*</span>:</label></td>
                <td colspan="3">
                    <label class="radio-inline">
                        <input type="radio" name="ts" {if $kid}{if $apply.ts==1} checked {/if}{/if}  value="1">是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" {if $kid}{if $apply.ts==0} checked {/if}{else/} checked {/if} name="ts" value="0">否
                    </label>
                </td>
            </tr>
        </table>
        <table class="table-bordered table" id="constructt" {if $kid}{if $apply.ts==0} style="display: none;" {/if}{else/} style="display: none;" {/if}>
            <tr class="info">
                <th class="font-bold">特殊条款备注(如是特殊合同则此项必填)：</th>
            </tr>
            <tr>
                <td>
                    <div class="ibox float-e-margins" style="margin-bottom: 0">
                        <div class="ibox-content no-padding">

                            <textarea id="tsmiaoshu" name="tsmiaoshu">
                                {if $kid}{$apply.tsmiaoshu}{/if}
                            </textarea>

                        </div>
                    </div>
                </td>
            </tr>
        </table>
        <table class="table-bordered table" id="constructg">
            <tr class="info">
                <th class="font-bold">合同概述：</th>
            </tr>
            <tr>
                <td>
                    <div class="ibox float-e-margins" style="margin-bottom: 0">
                        <div class="ibox-content no-padding">

                            <textarea  id="miaoshu" name="miaoshu" >
                                {if $kid}{$apply.miaoshu}{/if}
                            </textarea>

                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>温馨提示:本编辑不支持复杂表单提交，复杂表单请以附件形式提交</td>
            </tr>
            <tr>
                <td>
                    <p style="background: yellow">
                        注意事项：提交合同必须提供①营业执照副本扫描件②税务登记证副本扫描件③组织机构代码证副本扫描件。如是特殊合同则必须提交合同原件扫描件。可以为附件提交。如果不提交或者提交不全则合同有可能不会被通过。</p>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
                        <div id="uploader" class="wu-example">
                            <!--用来存放文件信息-->
                            <div id="thelist" class="uploader-list">
                               {volist name="fujian" id="fo"}
                                    <h4>{$fo.file_name}</h4>
                               {/volist}
                            </div>
                            <div class="btns">
                                <div id="picker">选择文件</div>
                                <button id="ctlBtn" class="btn btn-default">开始上传</button>
                            </div>
                            <input type="hidden" name="attach" id="attach" {if $kid} {if $apply.fujian} value="{$apply.fujian}" {/if} {/if} >
                        </div>
                        <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
                    </div>
                </td>
            </tr>
        </table>
        <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0">
         <input type="hidden" id="nodeKey" name="nodeKey"/>
          <input type="hidden" id="selectId" name="selectId"/>
          <input type="hidden" id="selectName" name="selectName"/>
          {volist name="btn.nextNodes" id="b"}
              {if $b.nodeName=='结束'}
              <input type="button" class="btn-danger btn" onclick="zuofei('{$b.nodeKey}','{$b.selectId}','{$b.selectName}')" value="点此作废"/>
              {else/}
              <input type="button" class="btn-info btn" onclick="baocun('{$b.nodeKey}','{$b.selectId}','{$b.selectName}')" value="保存并提交工作流"/>
              {/if}
            {/volist}
        </div>
    </form>
</div>
<!-- 全局js -->
{include file="Public/footer"}
<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote-zh-CN.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
 {if $kid}
    <script>
        $("#yydzp").val({$apply.yydz_provice})
        $.post('{:url("select/ecity")}',{id:$("#yydzp").val()},function (data) {
            $('[name=yydz_city]').html(data)
            $('[name=yydz_city]').val({$apply.yydz_city})
            $.post('{:url("select/ecounty")}',{id:$('[name=yydz_city]').val()},function (data) {
                $('[name=yydz_county]').html(data)
                $('[name=yydz_county]').val({$apply.yydz_county})
            })
        })

    </script>
{/if}
<script>

        //选定省份
        $('[name=yydz_provice]').on('change',function () {
            $.post('{:url("select/ecity")}',{id:$(this).val()},function (data) {
                $('[name=yydz_city]').html(data)
            })
        })

        //选定城市
        $('[name=yydz_city]').on('change',function () {
            $.post('{:url("select/ecounty")}',{id:$(this).val()},function (data) {
                $('[name=yydz_county]').html(data)
            })
        })
  function xiugaihetong(jid){
            $.post("{:url('xiugaihetonghao')}",{year:$("[name=htmc_nf]").val(),jid:jid},function(re){
                //alert(re);
               $('[name=htbh]').val(re)
            })
        }
//日期范围限制
    var start = {
        elem: '#start',
        format: 'YYYY-MM-DD',
        min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日


            if($("#start").val()!=""&&$("#end").val()!=""){
                var type=$("#mxtype").val();
                huizhi(type);
            }
        }
    };
    var end = {
        elem: '#end',
        format: 'YYYY-MM-DD',
        min: laydate.now(),
        max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
             if($("#start").val()!=""&&$("#end").val()!=""){
                var type=$("#mxtype").val();
                huizhi(type);
            }
        }
    };
    laydate(start);
    laydate(end);
    //计算费用率
    function jisuanfeiyonglv(){
        var xs=$(".tarzong").val().replace(/(^\s*)|(\s*$)/g, "");
        var ys=$(".salezong").val().replace(/(^\s*)|(\s*$)/g, "");
        if(xs!=""&&ys!=""){
            var res=(parseFloat(ys)/parseFloat(xs)*100).toFixed(2);
            $("[name=mbfyl]").val(res);
        }else{
            $("[name=mbfyl]").val('');
        }

    }
    //默认销售目标计算
    function morenxsjisuan(){
        var zongjine=0;
        $(".xstar").each(function(){
            var num_input=$(this);
            var num=num_input.val().replace(/(^\s*)|(\s*$)/g, "")
            if(num!=""){
                    if(isNaN(parseFloat(num))){
                        num_input.val(0);
                    }else{
                        num_input.val(parseFloat(num).toFixed(2));
                    }
                    zongjine+=parseFloat(num_input.val())

                }else{
                    num_input.val('');
                }
        })
        $(".tarzong").val(zongjine.toFixed(2))
        jisuanfeiyonglv();
    }
    {if $kid}
        {if $apply.detail_type==1}
             morenysjisuan();morenxsjisuan();
        {else/}
            yusuanjisuan();xiaoshoujisuan();
        {/if}
    {/if}
    //默认预算目标计算
    function morenysjisuan(){
        var zongjine=0;
        $(".ystar").each(function(){
            var num_input=$(this);
            var num=num_input.val().replace(/(^\s*)|(\s*$)/g, "")
            if(num!=""){
                    if(isNaN(parseFloat(num))){
                        num_input.val(0);
                    }else{
                        num_input.val(parseFloat(num).toFixed(2));
                    }
                    zongjine+=parseFloat(num_input.val())

                }else{
                    num_input.val('');
                }
        })
        $(".salezong").val(zongjine.toFixed(2))
        jisuanfeiyonglv();
    }
    //预算目标计算
    function yusuanjisuan(){
        var zongjine=0;
        $("#neirong2 table tr").each(function(){
            var jine=0;
            $(this).children().each(function(){
                var num_input=$(this).children();
                var num=num_input.val().replace(/(^\s*)|(\s*$)/g, "")
                if(num!=""){
                    if(isNaN(parseFloat(num))){
                        num_input.val(0);
                    }else{
                        num_input.val(parseFloat(num).toFixed(2));
                    }
                    jine+=parseFloat(num_input.val())

                }else{
                    num_input.val('');
                }
            })
            var mowei=$(this).children().eq(-1).children().val().replace(/(^\s*)|(\s*$)/g, "");
            if(mowei!="")
                jine-=parseFloat(mowei);
            $(this).children().eq(-1).children().val(jine.toFixed(2));
            zongjine+=jine;
        })
        $(".salezong").val(zongjine.toFixed(2))
        jisuanfeiyonglv();
    }
    //销售目标计算
    function xiaoshoujisuan(){
        var zongjine=0;
        $("#neirong1 table tr").each(function(){
            var jine=0;
            $(this).children().each(function(){
                var num_input=$(this).children();
                var num=num_input.val().replace(/(^\s*)|(\s*$)/g, "")
                if(num!=""){
                    if(isNaN(parseFloat(num))){
                        num_input.val(0);
                    }else{
                        num_input.val(parseFloat(num).toFixed(2));
                    }
                    jine+=parseFloat(num_input.val())

                }else{
                    num_input.val('');
                }
            })
            var mowei=$(this).children().eq(-1).children().val().replace(/(^\s*)|(\s*$)/g, "");
            if(mowei!="")
                jine-=parseFloat(mowei);
            $(this).children().eq(-1).children().val(jine.toFixed(2));
            zongjine+=jine;
        })
        $(".tarzong").val(zongjine.toFixed(2))
        jisuanfeiyonglv();
    }
    {if $kid}
    var xh={$xh};
    {else/}
    var xh=0;
    {/if}
    //自定义
    function zidingyi(){
         if($("#start").val()==""||$("#end").val()==""){
            swal({
                title: "错误",
                text:  "合同有效期必须填写完整",
                type: "warning"
            });
        }else{
            if($("#mxtype").val()==1){
                swal({
                    title: "错误",
                    text:  "默认状态下没有自定义",
                    type: "warning"
                });
            }else{
                xh++;
                //alert( $("#title1 table tr").html())
                $("#title1 table tr").children().eq(-1).before("<td class='text-center' style='min-width:150px' xh='"+xh+"'><input type='text' name='prolist[]' style='width:100px' class='form-control liandong"+xh+"' onblur='liandong("+xh+",this)' /><br/><input type='button' value='删除' onclick='shanchuduiying("+xh+")'/></td>")
                $("#title2 table tr").children().eq(-1).before("<td class='text-center' style='min-width:150px' xh='"+xh+"'><input type='text'  style='width:100px' class='form-control liandong"+xh+"' onblur='liandong("+xh+",this)' /><br/><input type='button' value='删除' onclick='shanchuduiying("+xh+")'/></td>")
                $("#neirong1 table tr").each(function(){
                    var namez=$(this).attr("namez");
                    $(this).children().eq(-1).before("<td style='min-width:150px' xh='"+xh+"'><input type='text' style='width:100px' class='form-control' onblur='xiaoshoujisuan()' name='"+namez+"'/></td>")
                })
                $("#neirong2 table tr").each(function(){
                    var namez=$(this).attr("namez");
                    $(this).children().eq(-1).before("<td style='min-width:150px' xh='"+xh+"'><input type='text' style='width:100px' class='form-control'  onblur='yusuanjisuan()' name='"+namez+"'/></td>")
                })
            }
        }

    }
    //新增文字联动
    function liandong(key,e){
        var str=e.value.replace(/(^\s*)|(\s*$)/g, "")
        if(str=="")
            $(".liandong"+key).val(str);
        else{
            $(".liandong"+key).val(str);
            var count=0;
            $("[name='prolist[]']").each(function(){
                if($(this).val()==str)
                    count++;
                if(count>1)
                    return false;
            })
            if(count>1){
                swal({
                    title: "错误",
                    text:  "出现重复的产品项",
                    type: "warning"
                });
                $(".liandong"+key).val('');
            }

        }
    }
    //产品品类系列删除
    function shanchuduiying(key){
        $("td[xh="+key+"]").remove();
        xiaoshoujisuan();yusuanjisuan();
    }
    function huizhi(typeid){
         if($("#kid").val()==""){
                $.post("{:url('gettable')}",{type:typeid,start:$("#start").val(),end:$("#end").val()},function(re){
                    var data=JSON.parse(re);
                    $("#title1").html(data["title1"])
                    $("#title2").html(data["title2"])
                    $("#neirong1").html(data["neirong1"])
                    $("#neirong2").html(data["neirong2"])
                    $("#timelan").html(data["times"])
                    xh=data["xh"]
                    var index=typeid-1;
                    $(".mxbtn").removeClass("active");
                    $(".mxbtn").eq(index).addClass("active");
                    $(".cb_box").show();

                })
            }else{
                //修改页面只做
                $.post("{:url('gettable')}",{type:typeid,start:$("#start").val(),end:$("#end").val()},function(re){
                    var data=JSON.parse(re);
                    $("#title1").html(data["title1"])
                    $("#title2").html(data["title2"])
                    $("#neirong1").html(data["neirong1"])
                    $("#neirong2").html(data["neirong2"])
                    $("#timelan").html(data["times"])
                    xh=data["xh"]
                    var index=typeid-1;
                    $(".mxbtn").removeClass("active");
                    $(".mxbtn").eq(index).addClass("active");
                    $(".cb_box").show();

                })
            }
    }
    $(".mxbtn").click(function(){

        if($("#start").val()==""||$("#end").val()==""){
            swal({
                title: "错误",
                text:  "合同有效期必须填写完整",
                type: "warning"
            });
        }else{

            if($("#mxtype").val()!=$(this).attr("mxtid")){
                
                 $("#mxtype").val($(this).attr("mxtid"))
                huizhi($(this).attr("mxtid"))
                 xiaoshoujisuan();yusuanjisuan();
            }
           
        }
    })
</script>
<script>
var fr={$from};
function zuofei(nodeKey,selectId,selectName){
  $("#nodeKey").val(nodeKey)
  $("#selectId").val(selectId)
  $("#selectName").val(selectName)
  $("#miaoshu").val($("#miaoshu").code());$("#tsmiaoshu").val($("#tsmiaoshu").code());
  if(confirm("您确定要作废这张申请但嘛？")){
         $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('zuofeichuli')}",
          data:$('#f1').serialize(),// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
            //alert(data);
            //var res=JSON.parse(data);
                    var res1=JSON.parse(data);
                            if(res1["state"]==1){
                              swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                   if(fr==1)
                                        location.href="{:url('index')}"
                                    else
                                        location.href="{:url('Workflowdb/index')}"
                                  //parent.layer.close(parent.layer.getFrameIndex(window.name))
                                  //
                                });

                          }else{
                            swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                          }           
          }
        });
  }
  
}
function baocun(nodeKey,selectId,selectName){
  $("#nodeKey").val(nodeKey)
  $("#selectId").val(selectId)
  $("#selectName").val(selectName)
  $("#miaoshu").val($("#miaoshu").code());$("#tsmiaoshu").val($("#tsmiaoshu").code());
  
         $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('baocunchuli')}",
          data:$('#f1').serialize(),// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
            //alert(data);
            //var res=JSON.parse(data);
                    var res1=JSON.parse(data);
                            if(res1["state"]==1){
                              swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                   if(fr==1)
                                        location.href="{:url('index')}"
                                    else
                                        location.href="{:url('Workflowdb/index')}"
                                  //parent.layer.close(parent.layer.getFrameIndex(window.name))
                                  //
                                });

                          }else{
                            swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                          }           
          }
        });
  
  
}
</script>
<script>
$("#same_faren").click(function(){
    if($("[name=cw_legalrepre]").val()==""){
        sweetAlert("", "法定代表人不能为空！", "error")
    }else{
        $("[name=cw_contact]").val($("[name=cw_legalrepre]").val())
        $("[name=cw_phone]").val($("[name=cw_lrphone]").val())
        $("[name=cw_email]").val($("[name=cw_lremail]").val())
    }
})
      //支付人搜索自动补全
    $(".cname").bsSuggest({
        url: "{:url('Apcaiwu/cnamejson')}",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias:{title: "名称"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onSetSelectValue', function (e, keyword, data) {
        $(this).closest('.input-group').hide().next('.selectedOnlyOne').show().find('.inin').html(keyword.key)
        $(this).val(keyword.id)

    });
     $('body').on('click','.selectedOnlyOne .close',function () {
        $(this).closest('.selectedOnlyOne').hide().find('.inin').html('')
        $(this).closest('.selectedOnlyOne').prev('.input-group').show().find('input').val('')
    })
    $(document).ready(function () {

        //选择授权区域
        $('#select_sqqy').on('click',function (data) {
            var index = layer.getFrameIndex(window.name)
            layer.open({
                type:2,
                area:['60%','60%'],
                maxmin:true,
                content:'{:url("sqqy")}'
            })
            return  false
        })

        //弹出授权品类树
        $('#select_sqpl').click(function () {
            top.layer.open({
                type:2,
                area:['60%','60%'],
                maxmin:true,
                content:'{:url("open/category")}',
                btn:['确定','关闭'],
                yes:function (i,o) {
                    var a = $(o).find('iframe').contents()
                    var data =  a.find("#data").val();

                    if(data){
                        data = JSON.parse(data)
                        var str = [];
                        var ids = [];
                        for(var j =0;j<data.length;j++){
                            str.push(data[j].title)
                            ids.push(data[j].id)
                        }
                        str = str.join(',')
                        ids = ids.join(',')

                        $('#sqpl').val(str)
                        $('[name=sqpl]').val(ids)
                    }
                    top.layer.close(i)
                }
            })
            return  false
        })


        //弹出授权品牌树
        $('#select_sqpp').click(function () {
            top.layer.open({
                type:2,
                area:['60%','60%'],
                maxmin:true,
                content:'{:url("open/brand")}',
                btn:['确定','关闭'],
                yes:function (i,o) {
                    var a = $(o).find('iframe').contents()
                    var data =  a.find("#data").val();

                    if(data){
                        data = JSON.parse(data)
                        var str = [];
                        var ids = [];
                        for(var j =0;j<data.length;j++){
                            str.push(data[j].title)
                            ids.push(data[j].id)
                        }
                        str = str.join(',')
                        ids = ids.join(',')

                        $('#sqpp').val(str)
                        $('[name=sqpp]').val(ids)
                    }
                    top.layer.close(i)
                }
            })
            return  false
        })



        //经销商搜索自动补全
        $("#cusName").bsSuggest({
            url: '{:url("bs/jxs")}',
            effectiveFields: ["id", "title"],
            searchFields: [ "title"],
            effectiveFieldsAlias: {title: "名称"},
            ignorecase: true,
            showHeader: true,
            showBtn: false,     //不显示下拉按钮
            delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
            idField: "id",
            keyField: "title",
            clearable: true
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword) {
           ``
            $('#htmc').html('<span>'+keyword.key+'</span>- <input type="text" name="htmc_nf" onblur="xiugaihetong('+keyword.id+')" value="{:date("Y")}" class="form-control" style="">年合同')
            
           tianchong(keyword.id);
        }).on('onUnsetSelectValue', function () {
            console.log("onUnsetSelectValue");
        });

        function tianchong(jid){
             //查询经销商的其他信息
            $.getJSON('{:url("jxs")}',{id:jid},function (data) {
                $('[name=jxsbh]').val(data.sn)
                $('[name=hznx]').val(data.cooptime)
                $('[name=qdlx]').val(data.channeltype)
                //$('[name=yddz_xxdz]').val(data.addr)
                $('[name=htbh]').val(data.htbh)
                //$("[name=htxsmb]").prop("readonly",false);
                //$("[name=ysfymb]").prop("readonly",false);
                $("[name=cw_legalrepre]").val(data.cw_legalrepre);
                $("[name=cw_lrphone]").val(data.cw_lrphone);
                $("[name=cw_lrmobile]").val(data.cw_lrmobile)
                $("[name=cw_lremail]").val(data.cw_lremail)
                $("[name=cw_qualification]").each(function(){
                    if($(this).val()==data.cw_qualification){
                        $(this).prop("checked",true);
                        return false;
                    }
                })
                $("[name=cw_taxsn]").val(data.cw_taxsn);
                $("[name=cw_bank]").val(data.cw_bank)
                $("[name=cw_banksn]").val(data.cw_banksn)
                $("[name=cw_mailaddr]").val(data.cw_mailaddr)
                $("[name=cw_zipcode]").val(data.cw_zipcode)
                $("[name=cw_contact]").val(data.cw_contact)
                $("[name=cw_phone]").val(data.cw_phone)
                $("[name=cw_email]").val(data.cw_email)
                $("[name=bs_contact]").val(data.bs_contact)
                $("[name=bs_phone]").val(data.bs_phone)
                $("[name=bs_mobile]").val(data.bs_mobile)
                $("[name=bs_fax]").val(data.bs_fax)
                $("[name=bs_rcv_unit]").val(data.bs_rcv_unit)
                $("[name=bs_rcv_addr]").val(data.bs_rcv_addr)
                $("[name=bs_rcv_one]").val(data.bs_rcv_one)
                $("[name=bs_rcv_phone]").val(data.bs_rcv_phone)
                $("#jxs_name").val(data.title);
            })
        }
        //关闭经销商选择
        $('#cusName_queding .close').click(function () {
            $(this).closest('#cusName_queding').hide().find('.inin').html('')
            $('#cusName_input').show().find('input').val('')
            $('[name=jxsbh]').val('')
            $('[name=hznx]').val('')
            $('[name=qdlx]').val('')
            $('[name=yddz_xxdz]').val('')
            $('#htmc').html('')
            $('[name=htbh]').val('')
            //$("[name=htxsmb]").prop("readonly",true).val("");
            //$("[name=ysfymb]").prop("readonly",true).val("");
            $("[name=cw_legalrepre]").val(""); 
            $("[name=cw_lrphone]").val("");
            $("[name=cw_lrmobile]").val("")
            $("[name=cw_lremail]").val("")
            $("[name=cw_qualification]").eq(0).prop("checked",true);
            $("[name=cw_taxsn]").val('')
            $("[name=cw_bank]").val("")
            $("[name=cw_banksn]").val("")
            $("[name=cw_mailaddr]").val("")
            $("[name=cw_zipcode]").val("")
            $("[name=cw_contact]").val("")
            $("[name=cw_phone]").val("")
            $("[name=cw_email]").val("")
            $("[name=bs_contact]").val("")
            $("[name=bs_phone]").val("")
            $("[name=bs_mobile]").val("")
            $("[name=bs_fax]").val("")
            $("[name=bs_rcv_unit]").val("")
            $("[name=bs_rcv_addr]").val("")
            $("[name=bs_rcv_one]").val("")
            $("[name=bs_rcv_phone]").val("")
            $("#jxs_name").val("");
        })

        //弹出经销商树
        $('#selectCus').click(function () {
            top.layer.open({
                type:2,
                area:['60%','60%'],
                maxmin:true,
                content:'{:url("open/jxs2")}',
                btn:['确定','关闭'],
                yes:function (i,o) {
                    var a = $(o).find('iframe').contents()
                    var id =  a.find("#renyuan").val();
                    var name =  a.find("#renyuanname").val();
                    if(id){
                        $('#cusName_queding').find('.inin').html(name)
                        $('#cusName_queding').find('input').val(id)
                        $('#cusName_queding').show()
                        $('#cusName_input').hide()
                    }
                    top.layer.close(i)
                }
            })
            return  false
        })


        $('#miaoshu').summernote({
            lang: 'zh-CN'
        });
        $('#tsmiaoshu').summernote({
            lang: 'zh-CN'
        });
        /*经销类型选择*/
        $("input:radio[name=jxlx]").click(function () {
            if ($("input:radio[name=jxlx]:checked").val()==2) {
                $("#swork").show();
                $('#sready').hide();
                $('#sqbt').text('授权系统')
            } else {
                $("#sready").show();
                $('#swork').hide();
                $('#sqbt').text('授权区域')
            }
        });


        /*是否为特殊合同*/
        $("input:radio[name=ts]").click(function () {
            if ($("input:radio[name=ts]").eq(1).prop("checked") != true) {
                $("#constructt").show();
            } else {
                $("#constructt").hide();
            }
            ;
        });



        /*签署人为法人按钮*/
        $("#arti_legal").click(function (event) {
            var $legal_people = $("#legal_people");
            var $legal_address = $("#legal_address");
            var $thislegal_people = $("#thislegal_people");
            var $thislegal_address = $("#thislegal_address");
            var $legal_peopleVal = $legal_people.val();
            var $legal_addressVal = $legal_address.val();
            if ($legal_peopleVal == "") {
                sweetAlert("", "法定代表人不能为空！", "error")
            } else if ($legal_addressVal == "") {
                sweetAlert("", "法定邮寄地址不能为空！", "error")
            } else {
                $thislegal_people.val($legal_peopleVal)
                $thislegal_address.val($legal_addressVal)
                $("[name=df_phone]").val($("[name=cw_lrphone]").val())
                $("[name=df_email]").val($("[name=cw_lremail]").val())
            }


        })

    });
    laydate({
        elem: '#startDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
        event: 'focus' //响应事件。如果没有传入event，则按照默认的click
    });
    
    function back() {
        location.href='{:url("index")}'
    }
    function resize() {
        var b_width = $(document).width();    //获取table宽度
        var width = $("#re_table").width();

        if (width > b_width) {
            $(document).width(width);     //设置浏览器宽度
            $("body").css("overflow-x", "hidden")
        } else {
            $("body").css("overflow-x", "auto")

        }
    }
</script>
   <script>
    $(".addnew").click(menuItem);
    function menuItem() {
    // 获取标识数据
    var dataUrl = $(this).attr('href'),
        dataIndex = $(this).data('index'),
        menuName = $.trim($(this).attr("title")),
        flag = true;
    if (dataUrl == undefined || $.trim(dataUrl).length == 0)return false;

    // 选项卡菜单已存在
    top.$('.J_menuTab').each(function () {
        if ($(this).data('id') == dataUrl) {
            if (!$(this).hasClass('active')) {
                $(this).addClass('active').siblings('.J_menuTab').removeClass('active');
                scrollToTab(this);
                // 显示tab对应的内容区
                top.$('.J_mainContent .J_iframe').each(function () {
                    if (top.$(this).data('id') == dataUrl) {
                        top.$(this).show().siblings('.J_iframe').hide();
                        return false;
                    }
                });
            }
            flag = false;
            return false;
        }
    });

    // 选项卡菜单不存在
    if (flag) {
        var str = '<a href="javascript:;" class="active J_menuTab" data-id="' + dataUrl + '">' + menuName + ' <i class="fa fa-times-circle"></i></a>';
        top.$('.J_menuTab').removeClass('active');

        // 添加选项卡对应的iframe
        var str1 = '<iframe class="J_iframe" name="iframe' + dataIndex + '" width="100%" height="100%" src="' + dataUrl + '" frameborder="0" data-id="' + dataUrl + '" seamless></iframe>';
        top.$('.J_mainContent').find('iframe.J_iframe').hide().parents('.J_mainContent').append(str1);

        //显示loading提示
//            var loading = layer.load();
//
//            $('.J_mainContent iframe:visible').load(function () {
//                //iframe加载完成后隐藏loading提示
//                layer.close(loading);
//            });
        // 添加选项卡
        top.$('.J_menuTabs .page-tabs-content').append(str);
        scrollToTab(top.$('.J_menuTab.active'));
    }
    return false;
}
//滚动到指定选项卡
function scrollToTab(element) {
    var marginLeftVal = calSumWidth(top.$(element).prevAll()), marginRightVal = calSumWidth(top.$(element).nextAll());
    // 可视区域非tab宽度
    var tabOuterWidth = calSumWidth(top.$(".content-tabs").children().not(".J_menuTabs"));
    //可视区域tab宽度
    var visibleWidth = top.$(".content-tabs").outerWidth(true) - tabOuterWidth;
    //实际滚动宽度
    var scrollVal = 0;
    if (top.$(".page-tabs-content").outerWidth() < visibleWidth) {
        scrollVal = 0;
    } else if (marginRightVal <= (visibleWidth - top.$(element).outerWidth(true) - top.$(element).next().outerWidth(true))) {
        if ((visibleWidth - top.$(element).next().outerWidth(true)) > marginRightVal) {
            scrollVal = marginLeftVal;
            var tabElement = element;
            while ((scrollVal - top.$(tabElement).outerWidth()) > (top.$(".page-tabs-content").outerWidth() - visibleWidth)) {
                scrollVal -= top.$(tabElement).prev().outerWidth();
                tabElement = top.$(tabElement).prev();
            }
        }
    } else if (marginLeftVal > (visibleWidth - top.$(element).outerWidth(true) - top.$(element).prev().outerWidth(true))) {
        scrollVal = marginLeftVal - top.$(element).prev().outerWidth(true);
    }
    top.$('.page-tabs-content').animate({
        marginLeft: 0 - scrollVal + 'px'
    }, "fast");
}
//计算元素集合的总宽度
function calSumWidth(elements) {
    var width = 0;
    top.$(elements).each(function () {
        width += top.$(this).outerWidth(true);
    });
    return width;
}


    </script>
           <!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script type="text/javascript">
   // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [{if $kid} {if $apply.fujian}value="{$apply.fujian}"{/if} {/if}];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });
     })

</script>
</body>

</html>
